package cn.zymall.user.controller;

import cn.zymall.common.controller.crud.BaseController;
import cn.zymall.common.model.User;
import cn.zymall.common.utils.redis.RedisUtil;
import cn.zymall.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author xuxianda
 * @Description: 用户控制器
 * @date 2020/8/15 10:15
 * @Copyright
 * @return
 **/
@RestController
@RequestMapping("/user")
public class UserController extends BaseController<UserService, User> {

    @Autowired
    private RedisUtil redisUtil;


    @Autowired
    private UserService userService;



    /**
     * @desc 测试方法
     * @return
     */
    @GetMapping("/test")
    public String test() {
        redisUtil.set("k", "v");
        return (String) redisUtil.get("k");
    }


   /**
    * @author：th
    * @Description：用户 id、name、phone 模糊查询
    * @Param：User
    * @return：List<User>
    **/
    @GetMapping("/vague")
    public List<User> queryCondition(String value){
        System.out.println(value);
        return userService.queryCondition(value);

    }

    /**
     * @author：th
     * @Description：根据手机号查询
     * @Param：用户手机号
     * @return：User
     **/
    @GetMapping("/phone")
    public User queryPhone(String phone){
        System.out.println(phone);
        return userService.queryPhone(phone);
    }


}
